﻿<UserControl x:Class="SLTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:SLTest"
    xmlns:MpegTs="clr-namespace:MatrixIO.IO.MpegTs;assembly=MatrixIO.IO.MPEGTS"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Style TargetType="sdk:TreeViewItem">
            <Setter Property="IsExpanded" Value="true" />
        </Style>
        <DataTemplate x:Key="StreamNode">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Type}"/>
                <TextBlock Text=" (PID "/>
                <TextBlock Text="{Binding Path=PacketIdentifier}"/>
                <TextBlock Text=")"/>
            </StackPanel>
        </DataTemplate>
        <sdk:HierarchicalDataTemplate x:Key="ProgramNode" ItemsSource="{Binding Path=Streams}" ItemTemplate="{StaticResource StreamNode}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding}"/>
            </StackPanel>
        </sdk:HierarchicalDataTemplate>
        <sdk:HierarchicalDataTemplate x:Key="SourceNode" ItemsSource="{Binding Path=Demuxer.Programs}" ItemTemplate="{StaticResource ProgramNode}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Url}"/>
            </StackPanel>
        </sdk:HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <sdk:TreeView Name="SourceTreeView" ItemsSource="{Binding Sources}" ItemTemplate="{StaticResource SourceNode}" Margin="0,0,4,0" SelectedItemChanged="SourceTreeView_SelectedItemChanged" />
        <sdk:GridSplitter Width="4"/>
        <Grid Grid.Column="1" Background="#FF525252">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <MediaElement Name="mediaElement" AutoPlay="True" MediaFailed="mediaElement_MediaFailed" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BufferingProgressChanged="mediaElement_BufferingProgressChanged" />
            <ProgressBar Grid.Row="1" Name="bufferingProgress"  Height="20" Minimum="0" Maximum="1"/>
        </Grid>
    </Grid>
</UserControl>
